package socket

import (
	"gdfs-center/socket/codec"
	"gdfs-center/socket/command"
)

//调度中心处理
func ControllerHandler(handler *ChannelInboundHandler) {
	//解码
	data := codec.DecoderData(handler.ByteBuffer)
	var resp *codec.Response
	if data != nil {
		switch data.Cmd {
		case "01": //上报存储服务器信息
			resp = command.AnalysisUploadInfo(handler.Conn, data)
		case "02": //心跳
			resp = command.Analysisheartbeat(data)
		case "05": //全量数据同步进度
			command.AnalysisSyncPercent(data)
		//case "06": //增量同步数据
		//    command.AnalysisProxySyncFile(data)
		case "09": //创建Tcp服务端返回
			command.AnalysisCreateTcpServerResult(data)
		case "0a": //接收到上报系统信息
			command.AnalysisUploadSysInfo(data)

		}
		//编码发送数据
		if resp != nil {
			handler.Conn.Write(codec.EncoderData(resp))
		}
	}

}
